package com.icinfo.cloud.provider.punish.config.enums;

import com.icinfo.cloud.provider.common.exception.BusinessException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 部门裁量启用的裁量类型
 *
 * @author Junfeng.Chen
 * @date 2024/1/31 8:52
 **/
@Getter
@AllArgsConstructor
public enum DiscretionTypeEnum {

    /**
     * 未启用裁量配置
     */
    NONE("0", "未启用"),
    /**
     * 市级裁量     改为 启用
     */
    CITY("1", "市级裁量"),
    /**
     * 单位（部门）裁量
     */
    ORG("2", "单位裁量"),
    ;

    /**
     * 编码
     */
    private final String code;
    /**
     * 描述
     */
    private final String desc;

    /**
     * 根据code获取枚举
     *
     * @param code
     * @return
     */
    public static DiscretionTypeEnum getByCode(String code) {
        for (DiscretionTypeEnum e : DiscretionTypeEnum.values()) {
            if (e.getCode().equals(code)) {
                return e;
            }
        }
        throw new BusinessException("转换枚举异常");
    }
}
